function fn(maxWeight, weight, value) {
    let res = []
    for (let j = 0; j <= maxWeight; j++) {
        res[j] = j >= weight[j] ? value[j] : 0
    }
    for (let i = 1; i < value.length; i++) {
        let next = []
        for (let j = 0; j <= maxWeight; j++) {
           if(j>=weight[i]){
            next[j] = Math.max(value[i] + res[j - weight[i]], res[j])
           }
        }
    }
}